#!/bin/bash
#

read -p "输入服务名:" fum

netstat -tunlp | grep "${fum}" &> /dev/null

dk=$(netstat -tunlp | grep "${fum}" | head -n 1 | awk '{print $4}' | awk -F: '{print $NF}')

pd=$(netstat -tunlp | grep "${fum}" | head -n 1 |awk '{print $7}' | awk -F"/" '{print $1}')
if [ $? -eq 0 ]; then
  echo "服务名称:${fum},端口:${dk},PID:${pd}"

fi
